import { defineStore } from 'pinia'
import { ref } from 'vue'

export const useHistoryStore = defineStore(
  'history',
  () => {
    const historyList = ref(['手机', '平板', '电脑', '电视'])
    const addHistory = (v) => {
      historyList.value = historyList.value.filter((item) => item != v)
      historyList.value.unshift(v)
    }
    const clearHistory = () => {
      historyList.value = []
    }
    return {
      historyList,
      addHistory,
      clearHistory
    }
  },
  { persist: true }
)
